///import js-src/lib/
///import js-src/com/
qui(function (require, exports, module) {
    VOD.Config = $.extend({}, {}, {
        BIG_PIC_MODE: 'style="width:264px;height:204px"',
        SMALL_PIC_MODE: 'style="width:104px;height:64px"',
        Global: {
            picWH: 'style="width:104px;height:64px"',
            smallPic: true,
            isClicked: false,
            error: '',
            channelInfo: [],
            sty2Data: {},
            d_sty2Data: [], // 广告头和尾
            noneDataNum: 0,
            fp_pos: 0,
            statisticOcrTitle: ""
        },

        HELP_DATA: [
            ["点击 + F 键", "打开始帧"],
            ["点击 + D 键", "打结束帧"],
            ["点击 + S 键", "打视频封面"],
            ["点击 + A 键", "提交打点"],
            ["点击 + V 键", "打删除(广告)的开始帧"],
            ["点击 + C 键", "打删除(广告)的结束帧"],
            ["点击 + Z 键", "提交删除"],
            ["点击 + Q 键", "片头、片尾精确化裁剪"],
            ["点击 + W 键", "时间片预览"],
            ["R 键", "标题OCR"],
            ["X 键", "拆条列表"],
            ["上、下、左、右方向键", "上、下、左、右切换"]
        ],
        HELP2_DATA: [
            ["点击 + F 键", "打入点"],
            ["点击 + D 键", "打出点"],
            ["点击 + S 键", "打视频封面"],
            ["点击 + Q 键", "入点、出点、封面精确化裁剪"],
            ["点击 + W 键", "时间片预览"],
            ["X 键", "拆条列表"],
            ["上、下、左、右方向键", "上、下、左、右切换"]
        ],
        ZOOM_HINT: {
            BIG: '您当前浏览器处于放大状态,按<strong>ctrl+0</strong>使用体验更佳!',
            SMALL: '您当前浏览器处于缩小状态,按<strong>ctrl+0</strong>使用体验更佳!'
        },
        PGC: 0,
        UGC: 1,
        adLibHead: 0, // 片头
        adLibTail: 1, // 片尾
        adLib: 2,// 广告

        RED_LAYOUT: '<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>',
//["index", "inpoint", "outpoint", "title","channel","album","cover", "status", "operate"]
        TABLE_COLMODEL_CONFIG: {
            index: {
                name: "index",
                index: 'index',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            inpoint: {
                name: "sTime",
                index: 'sTime',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            outpoint: {
                name: "eTime",
                index: 'eTime',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            title: {
                name: "title",
                index: 'title',
                title: false,
                width: 120,
                sortable: false
            },
            news_title: {
                name: "title",
                index: 'title',
                title: false,
                width: 205,
                sortable: false,
                formatter: function (v, o, r) {
                    return   VOD.Util.formatter.news_title(v, o, r);
                }
            },
            channel: {
                name: "channel",
                index: 'channel',
                title: false,
                width: 60,
                sortable: false,
                align: "center"
            },
            album: {
                name: "album",
                index: 'album',
                title: false,
                width: 60,
                sortable: false,
                align: "center"
            },
            cover: {
                name: "pic",
                index: 'pic',
                title: false,
                width: 45,
                sortable: false,
                align: "center"
            },
            status: {
                title: false,
                width: 60,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return   "已生成";
                }
            },
            operate_frame: {
                index: 'operate',
                title: false,
                width: 160,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return  VOD.Util.formatter.operate_frame(v, o, r);
                }
            },
            operate_advert: {
                index: 'operate',
                title: false,
                width: 160,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_advert(v, o, r);
                }
            },
            operate_news: {
                index: 'operate',
                title: false,
                width: 57,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_news(v, o, r);
                }
            },
            operate_news_merge:{
                index: 'operate',
                title: false,
                width: 57,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.operate_news_merge(v, o, r);
                }
            },

            error_hint: {
                title: false,
                width: 70,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.error_hint(v, o, r);
                }
            },
            news_id: {
                name: "regId",
                index: 'regId',
                title: false,
                width: 40,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.news_id(v, o, r);
                }

            },
            hidden_news_id:{
                name: "hidden_news_id",
                title: false,
                sortable: false,
                hidden: true,
                align: "center",
                formatter: function (v, o, r) {
                    return VOD.Util.formatter.hidden_news_id(v, o, r);
                }
            }
        },
        TABLE_FRAME_LIST: {
            multiselect: false,
            datatype: "local",
            height: 450,
            rowNum: 10,

            caption: "拆条列表",
            colNames: ["序号" , "入点", "出点", "标题 ", "频道", "专辑", "封面", "状态", "操作" ],
            colModel: ["index", "inpoint", "outpoint", "title", "channel", "album", "cover", "status", "operate_frame"],
            pager: "#frame_pager",
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("frame_list", "frame_pager", VOD.Config.PageBeanFrame, pgButton);
                if (retValue != null) {
                    $("#frame_list")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },
        TABLE_ADVERT_LIST: {
            multiselect: false,
            datatype: "local",
            height: 450,
            caption: "广告列表",
            colNames: ["序号" , "入点", "出点", "标题 ", "状态", "操作"  ],
            colModel: ["index", "inpoint", "outpoint", "title", "status", "operate_advert"],
            rowNum: 10,
            pager: "#advert_pager",
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("advert_list", "advert_pager", VOD.Config.PageBeanAdvert, pgButton);
                if (retValue != null) {
                    $("#advert_list")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },
        TABLE_NEWS_LIST: {
            multiselect: false,
            datatype: "local",
            height: window.screen.height - 1080 + 355 ,
            toolbar: [true, "top"],
            caption: "新闻拆条列表",
            colNames: ["序号", "标题" , "入点", "出点", "封面 ", "操作","隐藏主键"],
            colModel: ["news_id", "news_title", "inpoint", "outpoint", "cover", "operate_news","hidden_news_id"],
            pager: "#news_pager",
//            multiselect: true,
            rowNum: 100,
            onPaging: function (pgButton) {
                var retValue = VOD.Util.pageBeanPageHandler("news_list", "news_pager", VOD.Config.PageBeanNews, pgButton);
                if (retValue != null) {
                    $("#news_list")[0].addJSONData(retValue)
                }
                return "stop";
            },
            beforeSelectRow: function (rowid, e) {
                var describedby = $(e.target).attr("aria-describedby");
                if(describedby != null){
                    var cellKey =  describedby.replace("news_list_", "");
                    switch (cellKey) {
                        case "checked":
                            return false;
                        case "pic":
                        case "sTime":
                        case "eTime":
                            var rowData = VOD.Config.PageBeanNews.findData("regId", rowid);
                            VOD.Util.setHighLight(rowData);
                            VOD.Util.fromLIstJump(parseInt($(e.target).html()));
                            return true;
                        case "myTitle":
                            var oldValue =  $(e.target).html();
                            $(e.target).html("<input type='text' style='width:185px' data-id='"+rowid+"'   onblur='VOD.Util.doChangeTitle(this)' value='"+oldValue+"'>");
                            var inputElement = $(e.target).find("input");
                            VOD.Util.limitWordCount(inputElement, 43);
                            inputElement.focus();
                            break;
                    }
                }
                var rowData = VOD.Config.PageBeanNews.findData("regId", rowid);
                VOD.Util.setHighLight(rowData);
                VOD.Util.fromLIstJump(rowData.sTime);
                if(e.target.tagName == "A"){
                    $("#news_list").jqGrid('setSelection', rowid);
                }
                return true;
            },
            localReader: {
                id: "regId",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            }
        },


        INFO_COMPLETE_WAIT_DO: "拆条完成，还有N条未审核",
        INFO_UN_COMPLETE: "正在拆条，还有N条未审核",
        INFO_COMPLETE: "等待开播",
        PageBeanFrame: null,
        PageBeanAdvert: null,
        PageBeanNews: null,
        PageBeanTemp: null,
        INIT_SUCCESS: false,
        EDIT_MODE_TYPE: 1,// 1:拆条参数,2:新闻发布
        SORT_RULE:{
          asc_news_regId:function(a, b) {
            return a.regId > b.regId ? 1 : -1
          },
          asc_news_sTime:function (a, b) {
              return a.sTime > b.sTime ? 1 : -1
          }
        },
        KEY_CODE: {
            A: 65,
            C: 67,
            D: 68,
            F: 70,
            ESC: 27,
            Q: 81,
            R: 82,
            S: 83,
            V: 86,
            W: 87,
            X: 88,
            Z: 90,
            ZERO: 48,
            LEFT: 37,
            UP: 38,
            RIGHT: 39,
            DOWN: 40
        }
    })
})